@extends('adminlte::page')

@section('title', '轮播图列表')

@section('content_header')
    {{--<h1></h1>--}}
@stop

<style>
    .btn-sm{
        width: 25% !important;
    }
</style>

@section('content')
    <div class="box box-danger">
        <div class="box-header with-border">
            <h3 class="box-title">新闻检索</h3>
        </div>
        <div class="box-body">
            <div class="row">

                <form action="{{ route('news.show') }}">
                    <div class="col-xs-3">
                        <select class="form-control" name="channel">
                            <option value="">栏目类型</option>
                            @foreach( $channels  as $channel)
                                <option value="{{ $channel->id }}" {{ $request->channel==$channel->id ? 'selected' : '' }}>{{ $channel->name }}</option>
                            @endforeach
                        </select>
                    </div>
                    <div class="col-xs-3">
                        <input type="text" name="name" class="form-control" placeholder="按标题搜索" value="{{ $request->name }}">
                    </div>
                    <div class="col-xs-3">
                        <button type="submit" class="btn  btn-success">搜索</button>
                        <a type="button" class="btn  btn-default" href="{{ route('news.show') }}">重置</a>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <div class="box">
        <div class="box-header with-border">
            <h3 class="box-title">新闻列表</h3>
            {{--<div class="box-tools">--}}
                {{--<div class="input-group input-group-sm" style="width: 150px;">--}}
                    {{--<input type="text" name="table_search" class="form-control pull-right" placeholder="Search">--}}

                    {{--<div class="input-group-btn">--}}
                        {{--<button type="submit" class="btn btn-default"><i class="fa fa-search"></i></button>--}}
                    {{--</div>--}}
                {{--</div>--}}
            {{--</div>--}}
        </div>
        <div class="box-body">
            <table class="table table-bordered">
                <tbody><tr>
                    <th style="width: 7%">新闻ID</th>
                    {{--<th>图片</th>--}}
                    <th>标题</th>
                    <th>栏目</th>
                    <th>操作</th>
                </tr>
                @foreach($news as $new)
                    <tr>
                        <td>
                            {{ $new->id }}
                        </td>

                        <td>
                            @if($new->img )
                                <img src="{{$new->img}}" alt="" width="70">
                            @endif
                            <a href="{{ route('article_detail' ,['article'=>$new->id]) }}" target="_blank" style="color: black">
                                {{ $new->title }}
                            </a>
                        </td>

                        <td style="width: 10%">
                            {{ optional($new->channel)->name }}
                        </td>

                        <td style="width: 16%">
                            <a   href="{{ route('news.edit',['news'=>$new->id]) }}" >
                                <span class="label label-success">编辑</span>
                            </a>

                            <a href="{{ route('news.delete',['news'=>$new->id]) }}" onclick="if (!confirm('确定要删除吗?')) { return false }">
                                <span class="label label-danger">删除</span>
                            </a>
                        </td>
                    </tr>
                @endforeach



                </tbody></table>
            {{ $news->appends(['channel' => request('channel'),'name'=>request('name')])->links() }}
        </div>
    </div>
@stop